#ifndef _H_EXCHANGESERVER_H_
#define _H_EXCHANGESERVER_H_

#include "XServerHandler.h"
#include <boost/thread.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/atomic.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/property_tree/ptree.hpp>  
#include <boost/property_tree/json_parser.hpp>  
#include <boost/property_tree/xml_parser.hpp>  

namespace XTrade {

	class ExchangeServer;

	class ExchangeServer
		: public XServerHandlerSpi
	{
	private:
		XServerHandlerApi* api_;
	public:
		ExchangeServer();

		inline XServerHandlerApi* api() {
			return api_;
		}

		bool start(boost::property_tree::ptree& cfg);
		void stop();

		void handle_close(const x_size_t peer);

		void handle_io_accept(const x_size_t peer);

		x_int_t handle_work_packet(const x_size_t peer, const x_buffer_t* recv_data, x_buffer_t*& send_data);

		x_int_t on_handle_work_packet(const x_size_t peer, const x_buffer_t* recv_data, x_buffer_t*& send_data, bool is_last);
	};
}

#endif//_H_EXCHANGESERVER_H_
